import Vue from "vue";
import Router from "vue-router";

Vue.use(Router);

/* Layout */
import Layout from "@/layout";

/* Router Modules */
import commonRouter from "./modules/common"; // 无权限路由
import twoPhaseRouter from "./modules/twoPhase"; // 土地复垦路由（二期）
import twoPhaseYwRouter from "./modules/twoPhaseYw"; // 土地复垦业务端路由（二期）
import threePhaseRouter from "./modules/threePhase"; // 国土整治路由（三期）
import threePhaseYwRouter from "./modules/threePhaseYw"; // 国土整治路由业务端路由（三期）

// import policyAnnouceReplyRouter from './modules/policyAnnouceReply'
// import mixcxRouter from './modules/mixcx'
// import statisticsRouter from './modules/statistics'

import systemRouter from "./modules/system";
import integrityRouter from "./modules/integrity";

import gtzzzz from "./stage/gtzzzz";
import ncjsydfk from "./stage/ncjsydfk";
import tdcb from "./stage/tdcb";
import gdzljc from "./stage/gdzljc";

import implementGtzzzz from "./implement/implementGtzzzz";
import implementNcjsydfk from "./implement/implementNcjsydfk";
import implementTdcb from "./implement/implementTdcb";
import implementGdzljc from "./implement/implementGdzljc";

import projectManagementRouter from "./modules/projectManagement";
import plannDesignBudget from "./modules/plannDesignBudget";
import earlyMappingRouter from "./modules/earlyMapping";
import feasibilityStudy from "./modules/feasibilityStudy";
import planningDesignApplication from "./modules/planningDesignApplication";

import budgetReviewAndPlanRelease from "./modules/budgetReviewAndPlanRelease";
import projectImplementation from "./modules/projectImplementation";
import implementationUnit from "./modules/implementationUnit";
import projectOrganization from "./modules/projectOrganization";
import designChange from "./modules/designChange";
import projectCompletionAndSelfVerification from "./modules/projectCompletionAndSelfVerification";
import supervisionAcceptance from "./modules/supervisionAcceptance";
import completedMapping from "./modules/completedMapping";
import completedAcceptance from "./modules/completedAcceptance";
import settlementAndMaintenance from "./modules/settlementAndMaintenance";

import tongji from "./modules/tongji";

/**
 * Note: 子菜单仅在路由 children.length >= 1 时出现
 * 详细请查看: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 *
 * hidden: true                   如果设置true，item将不显示在sidebar（默认false）
 * alwaysShow: true               if set true, will always show the root menu
 *                                if not set alwaysShow, when item has more than one children route,
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noRedirect           if set noRedirect will no redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    roles: ['admin','editor']    control the page roles (you can set multiple roles)
    title: 'title'               the name show in sidebar and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar
    breadcrumb: false            if set false, the item will hidden in breadcrumb(default is true)
    activeMenu: '/example/list'  if set path, the sidebar will highlight the path you set
  }
 */

/**
 * 无权限路由
 * 没有权限要求的路由
 * 所有角色可以访问
 */
export const constantRoutes = commonRouter;

/**
 * 权限路由
 * 具有权限要求的路由
 * meta: {
     roles: ['admin','editor']
   }
 */
export let asyncRoutes = [
  //   twoPhaseRouter, // 二期路由
  //   threePhaseRouter, // 三期路由
  //   systemRouter, // 系统管理
  //   // 404 页面路由必须放在末尾
  //   { path: "*", redirect: "/404", hidden: true }
];

// asyncRoutes = asyncRoutes.concat(twoPhaseYwRouter).concat([
  asyncRoutes = asyncRoutes.concat(twoPhaseYwRouter, threePhaseYwRouter,tongji).concat([
  // asyncRoutes = asyncRoutes.concat([
  twoPhaseRouter, // 二期路由
  threePhaseRouter, // 三期路由
  systemRouter, // 系统管理
  integrityRouter, // 诚信管理

  gtzzzz,
  ncjsydfk,
  // tdcb,
  // gdzljc,
  implementGtzzzz,
  implementNcjsydfk,
  // implementTdcb,
  // implementGdzljc,

  // projectManagementRouter,
  // planningDesignApplication,
  // earlyMappingRouter,
  // feasibilityStudy,
  // plannDesignBudget,
  // budgetReviewAndPlanRelease,
  // projectImplementation,
  // implementationUnit,
  // projectOrganization,
  // designChange,
  // projectCompletionAndSelfVerification,
  // supervisionAcceptance,
  // completedMapping,
  // completedAcceptance,
  // settlementAndMaintenance,

  // 404 页面路由必须放在末尾
  { path: "*", redirect: "/404", hidden: true }
]);

const createRouter = () =>
  new Router({
    // mode: 'history', // require service support
    scrollBehavior: () => ({ y: 0 }),
    routes: constantRoutes
  });

const router = createRouter();

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter();
  router.matcher = newRouter.matcher; // reset router
}

export default router;
